<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
    <th:block th:include="include :: header('修改大区商城配件管理')" />
    <th:block th:include="include :: bootstrap-fileinput-css"/>
</head>
<body class="white-bg">
    <div class="wrapper wrapper-content animated fadeInRight ibox-content">
        <form class="form-horizontal m" id="form-agentParts-edit" th:object="${zsyhAgentParts}">
            <h4 class="form-header h4">大区商城配件管理信息</h4>
            <input name="id" th:field="*{id}" type="hidden">
            <div class="form-group">    
                <label class="col-sm-3 control-label">大区会长Id：</label>
                <div class="col-sm-8">
                    <input name="agentId" th:field="*{agentId}" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">配件名称：</label>
                <div class="col-sm-8">
                    <input name="partsName" th:field="*{partsName}" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">配件编码：</label>
                <div class="col-sm-8">
                    <input name="partsNumber" th:field="*{partsNumber}" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">配件分类id：</label>
                <div class="col-sm-8">
                    <select name="partsType" class="form-control m-b">
                        <option value="">所有</option>
                    </select>
                    <span class="help-block m-b-none"><i class="fa fa-info-circle"></i> 代码生成请选择字典属性</span>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">配件品牌：</label>
                <div class="col-sm-8">
                    <input name="partsBrand" th:field="*{partsBrand}" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">配件描述：</label>
                <div class="col-sm-8">
                    <textarea name="partsDetails" class="form-control">[[*{partsDetails}]]</textarea>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">配件 主图：</label>
                <div class="col-sm-8">
                    <input type="hidden" name="partsImages" th:field="*{partsImages}">
                    <div class="file-loading">
                        <input class="form-control file-upload" id="partsImages" name="file" type="file">
                    </div>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">配件详细信息：</label>
                <div class="col-sm-8">
                    <textarea name="partsRemarks" class="form-control">[[*{partsRemarks}]]</textarea>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">是否今日热卖：</label>
                <div class="col-sm-8">
                    <select name="isTodayHot" class="form-control m-b" th:with="type=${@dict.getType('zsyh_yesno')}">
                        <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}" th:field="*{isTodayHot}"></option>
                    </select>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">是否新品推荐：</label>
                <div class="col-sm-8">
                    <select name="isNewPush" class="form-control m-b" th:with="type=${@dict.getType('zsyh_yesno')}">
                        <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}" th:field="*{isNewPush}"></option>
                    </select>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">是否好物优选：</label>
                <div class="col-sm-8">
                    <select name="isGoodChoice" class="form-control m-b" th:with="type=${@dict.getType('zsyh_yesno')}">
                        <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}" th:field="*{isGoodChoice}"></option>
                    </select>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">是否热门推荐：</label>
                <div class="col-sm-8">
                    <select name="isHotPush" class="form-control m-b" th:with="type=${@dict.getType('zsyh_yesno')}">
                        <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}" th:field="*{isHotPush}"></option>
                    </select>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">是否包邮：</label>
                <div class="col-sm-8">
                    <select name="isPost" class="form-control m-b" th:with="type=${@dict.getType('zsyh_yesno')}">
                        <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}" th:field="*{isPost}"></option>
                    </select>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">是否上架：</label>
                <div class="col-sm-8">
                    <select name="isShow" class="form-control m-b" th:with="type=${@dict.getType('zsyh_yesno')}">
                        <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}" th:field="*{isShow}"></option>
                    </select>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">订购最低数量：</label>
                <div class="col-sm-8">
                    <input name="partsQuantity" th:field="*{partsQuantity}" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">排序数字越大，排序约靠前：</label>
                <div class="col-sm-8">
                    <input name="partsSort" th:field="*{partsSort}" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">分类 1配件 2整机：</label>
                <div class="col-sm-8">
                    <select name="partsClassification" class="form-control m-b" th:with="type=${@dict.getType('parts_class')}">
                        <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}" th:field="*{partsClassification}"></option>
                    </select>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">配件的单位：</label>
                <div class="col-sm-8">
                    <input name="partsUnit" th:field="*{partsUnit}" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">平台配件ID：</label>
                <div class="col-sm-8">
                    <input name="partsId" th:field="*{partsId}" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">配件分类1平台配件2自有配件：</label>
                <div class="col-sm-8">
                    <select name="partsDistinguish" class="form-control m-b" th:with="type=${@dict.getType('parts_brand')}">
                        <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}" th:field="*{partsDistinguish}"></option>
                    </select>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">注意事项：</label>
                <div class="col-sm-8">
                    <textarea name="partsAttention" class="form-control">[[*{partsAttention}]]</textarea>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">使用说明：</label>
                <div class="col-sm-8">
                    <textarea name="partsInstructions" class="form-control">[[*{partsInstructions}]]</textarea>
                </div>
            </div>
            <h4 class="form-header h4">会长商城产品规格信息</h4>
            <div class="row">
                <div class="col-sm-12">
                    <button type="button" class="btn btn-white btn-sm" onclick="addColumn()"><i class="fa fa-plus"> 增加</i></button>
                    <button type="button" class="btn btn-white btn-sm" onclick="sub.delColumn()"><i class="fa fa-minus"> 删除</i></button>
                    <div class="col-sm-12 select-table table-striped">
                        <table id="bootstrap-table"></table>
                    </div>
                </div>
            </div>
        </form>
    </div>
    <th:block th:include="include :: footer" />
    <th:block th:include="include :: bootstrap-fileinput-js"/>
    <script th:inline="javascript">
        var prefix = ctx + "zsyh/agentParts";
        var isPostDatas = [[${@dict.getType('zsyh_yesno')}]];
        var isShowDatas = [[${@dict.getType('zsyh_yesno')}]];
        $("#form-agentParts-edit").validate({
            focusCleanup: true
        });

        function submitHandler() {
            if ($.validate.form()) {
                $.operate.save(prefix + "/edit", $('#form-agentParts-edit').serialize());
            }
        }

        $(".file-upload").each(function (i) {
            var val = $("input[name='" + this.id + "']").val()
            $(this).fileinput({
                'uploadUrl': ctx + 'common/uploadOSS',
                initialPreviewAsData: true,
                initialPreview: [val],
                maxFileCount: 1,
                autoReplace: true
            }).on('fileuploaded', function (event, data, previewId, index) {
                $("input[name='" + event.currentTarget.id + "']").val(data.response.url)
            }).on('fileremoved', function (event, id, index) {
                $("input[name='" + event.currentTarget.id + "']").val('')
            })
            $(this).fileinput('_initFileActions');
        });

        $(function() {
            var options = {
                data: [[${zsyhAgentParts.zsyhAgentPartsattributeList}]],
                pagination: false,
                showSearch: false,
                showRefresh: false,
                showToggle: false,
                showColumns: false,
                sidePagination: "client",
                columns: [{
                    checkbox: true
                },
                {
                    field: 'index',
                    align: 'center',
                    title: "序号",
                    formatter: function (value, row, index) {
                    	var columnIndex = $.common.sprintf("<input type='hidden' name='index' value='%s'>", $.table.serialNumber(index));
                    	return columnIndex + $.table.serialNumber(index);
                    }
                },
                {
                    field: 'attributeName',
                    align: 'center',
                    title: '属性名称',
                    formatter: function(value, row, index) {
                        var html = $.common.sprintf("<input class='form-control' type='text' name='zsyhAgentPartsattributeList[%s].attributeName' value='%s'>", index, value);
                        return html;
                    }
				},
                {
                    field: 'updateTime',
                    align: 'center',
                    title: '更新时间',
                    formatter: function(value, row, index) {
                        var html = $.common.sprintf("<input class='form-control' type='text' name='zsyhAgentPartsattributeList[%s].updateTime' value='%s'>", index, value);
                        return html;
                    }
				},
                {
                    field: 'createTime',
                    align: 'center',
                    title: '创建时间',
                    formatter: function(value, row, index) {
                        var html = $.common.sprintf("<input class='form-control' type='text' name='zsyhAgentPartsattributeList[%s].createTime' value='%s'>", index, value);
                        return html;
                    }
				},
                {
                    field: 'attributeSort',
                    align: 'center',
                    title: '排序 排序数字越大，排序约靠前',
                    formatter: function(value, row, index) {
                        var html = $.common.sprintf("<input class='form-control' type='text' name='zsyhAgentPartsattributeList[%s].attributeSort' value='%s'>", index, value);
                        return html;
                    }
				},
                {
                    field: 'attributeSalePrice',
                    align: 'center',
                    title: '销售价',
                    formatter: function(value, row, index) {
                        var html = $.common.sprintf("<input class='form-control' type='text' name='zsyhAgentPartsattributeList[%s].attributeSalePrice' value='%s'>", index, value);
                        return html;
                    }
				},
                {
                    field: 'attributeWarranty',
                    align: 'center',
                    title: '补助金有效期/质保期单位：月 ',
                    formatter: function(value, row, index) {
                        var html = $.common.sprintf("<input class='form-control' type='text' name='zsyhAgentPartsattributeList[%s].attributeWarranty' value='%s'>", index, value);
                        return html;
                    }
				},
                {
                    field: 'attributeInstall',
                    align: 'center',
                    title: '二维码有效期 单位：月',
                    formatter: function(value, row, index) {
                        var html = $.common.sprintf("<input class='form-control' type='text' name='zsyhAgentPartsattributeList[%s].attributeInstall' value='%s'>", index, value);
                        return html;
                    }
				},
                {
                    field: 'attributePayPrice',
                    align: 'center',
                    title: '质保期内损坏 赔付金额',
                    formatter: function(value, row, index) {
                        var html = $.common.sprintf("<input class='form-control' type='text' name='zsyhAgentPartsattributeList[%s].attributePayPrice' value='%s'>", index, value);
                        return html;
                    }
				},
                {
                    field: 'attributeFreeWarranty',
                    align: 'center',
                    title: '质保期单位：月 产品质保期',
                    formatter: function(value, row, index) {
                        var html = $.common.sprintf("<input class='form-control' type='text' name='zsyhAgentPartsattributeList[%s].attributeFreeWarranty' value='%s'>", index, value);
                        return html;
                    }
				},
                {
                    field: 'attributeRemarks',
                    align: 'center',
                    title: '属性备注',
                    formatter: function(value, row, index) {
                        var html = $.common.sprintf("<input class='form-control' type='text' name='zsyhAgentPartsattributeList[%s].attributeRemarks' value='%s'>", index, value);
                        return html;
                    }
				},
                {
                    field: 'attributeLogo',
                    align: 'center',
                    title: '属性logo',
                    formatter: function(value, row, index) {
                        var html = $.common.sprintf("<input class='form-control' type='text' name='zsyhAgentPartsattributeList[%s].attributeLogo' value='%s'>", index, value);
                        return html;
                    }
				},
                {
                    field: 'isPost',
                    align: 'center',
                    title: '是否包邮 1包邮 ',
                    formatter: function(value, row, index) {
                        var name = $.common.sprintf("zsyhAgentPartsattributeList[%s].isPost", index);
                        return $.common.dictToSelect(isPostDatas, value, name);
                    }
                },
                {
                    field: 'isShow',
                    align: 'center',
                    title: '是否上架',
                    formatter: function(value, row, index) {
                        var name = $.common.sprintf("zsyhAgentPartsattributeList[%s].isShow", index);
                        return $.common.dictToSelect(isShowDatas, value, name);
                    }
                },
                {
                    field: 'attributeRetailPrice',
                    align: 'center',
                    title: '建议零售价',
                    formatter: function(value, row, index) {
                        var html = $.common.sprintf("<input class='form-control' type='text' name='zsyhAgentPartsattributeList[%s].attributeRetailPrice' value='%s'>", index, value);
                        return html;
                    }
				},
                {
                    field: 'attributeAdvantage',
                    align: 'center',
                    title: '产品优势描述',
                    formatter: function(value, row, index) {
                        var html = $.common.sprintf("<input class='form-control' type='text' name='zsyhAgentPartsattributeList[%s].attributeAdvantage' value='%s'>", index, value);
                        return html;
                    }
				},
                {
                    field: 'attributeInstructions',
                    align: 'center',
                    title: '产品使用说明书',
                    formatter: function(value, row, index) {
                        var html = $.common.sprintf("<input class='form-control' type='text' name='zsyhAgentPartsattributeList[%s].attributeInstructions' value='%s'>", index, value);
                        return html;
                    }
				
                }]
            };
            $.table.init(options);
        });

        function addColumn() {
            var count = $("#" + table.options.id).bootstrapTable('getData').length;
            sub.editColumn();
        	
            $("#" + table.options.id).bootstrapTable('insertRow', {
                index: count,
                row: {
                    index: $.table.serialNumber(count),
                    attributeName: "",
                    updateTime: "",
                    createTime: "",
                    attributeSort: "",
                    attributeSalePrice: "",
                    attributeWarranty: "",
                    attributeInstall: "",
                    attributePayPrice: "",
                    attributeFreeWarranty: "",
                    attributeRemarks: "",
                    attributeLogo: "",
                    isPost: "",
                    isShow: "",
                    attributeRetailPrice: "",
                    attributeAdvantage: "",
                    attributeInstructions: ""
        	    }
            });
        }
    </script>
</body>
</html>